package com.edgclub.edg.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.edgclub.edg.R;
import com.edgclub.edg.model.result.EDGTeamType;
import com.edgclub.edg.utils.GlideUtil.GlideUtils;

import java.util.ArrayList;

/**
 */
public class EDGTeamPopAdapter extends BaseAdapter {
    private Context mContext;

    private ArrayList<EDGTeamType> list;

    private GlideUtils glideUtils;

    private ViewHolder holder;

    private int selectedIndex;


    public EDGTeamPopAdapter(Context mContext) {
        this.mContext = mContext;
        glideUtils = new GlideUtils();
    }

    public ArrayList<EDGTeamType> getList() {
        return list;
    }

    public void setList(ArrayList<EDGTeamType> list) {
        this.list = list;
    }

    public void selectIndex(int index){
        this.selectedIndex = index;
    }


    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int arg0) {
        return 0;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup viewGroup) {
        if (null == convertView) {
            convertView = LayoutInflater.from(mContext).inflate(
                    R.layout.pop_team_menu_item, null);

            holder = new ViewHolder();
            holder.imgv_icon = (ImageView) convertView.findViewById(R.id.imgv_icon);
            holder.tv_title = (TextView) convertView.findViewById(R.id.tv_title);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        glideUtils.Glidde_loadImage(mContext,list.get(i).getDefaultLogo(),holder.imgv_icon);
        holder.tv_title.setText(list.get(i).getCategory()+"");
        if(i==selectedIndex){
            holder.tv_title.setSelected(true);
        }else{
            holder.tv_title.setSelected(false);
        }
        return convertView;
    }


    public class ViewHolder {

        public ImageView imgv_icon;
        private TextView tv_title;
    }


}
